<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>添加文章</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0"><!-- 确保适当的绘制和触屏缩放 -->
	<link rel="stylesheet" href="{$url_css}bootstrap.min.css" type="text/css">
	<link rel="stylesheet" href="{$url_css}admin.css" type="text/css">
	<link rel="stylesheet" href="{$url_js}fileinput/css/fileinput.min.css" type="text/css">

	<script type="text/javascript" src="{$url_js}jquery-2.2.0.min.js"></script>
	<script type="text/javascript" src="{$url_js}bootstrap.min.js"></script>
	<script type="text/javascript" src="{$url_js}calendar/WdatePicker.js"></script>
	{*<script type="text/javascript" src="{$url_js}AutoTips.js"></script>*}
	{*<script type="text/javascript" src="{$url_js}jquery-ui.min.js"></script>*}
	{*<script type="text/javascript" src="{$url_js}jquery.contextmenu.r2.js"></script>*}
	<script type="text/javascript" src="{$url_js}fileinput/js/fileinput.min.js"></script>
	<script type="text/javascript" src="{$url_js}fileinput/js/locales/zh.js"></script>
	<style type="text/css">
		{literal}
		.cover_img_div input[type="file"] {
			cursor: inherit;
			opacity: 0;
			z-index: 99;
		}

		.atlas1_img_div input[type="file"] {
			cursor: inherit;
			opacity: 0;
			z-index: 99;
		}

		.div-child-left {
			position: absolute;
			top: 0px;
			left: 0;
			width: 0px;
		}

		.cover_img_div {
			min-width: 163px;
			position: relative;
			float: left;
			margin: 4px;
			border: 1px solid #ddd;
			border-radius: 4px;
			text-align: center;
		}

		.atlas_img_div {
			width: 360px;
			height: 240px;
			position: relative;
			float: left;
			border: 1px solid #ddd;
			border-radius: 4px;
			text-align: center;
		}

		.input-file {
			position: absolute;
			left: 0;
			bottom: 0;
			width: 85px;
			z-index: 1;
		}

		.delete_btn {
			position: absolute;
			right: 0;
			bottom: 0;
			width: 55px;
			z-index: 1;
		}

		.div_btn {
			width: 100%;
		}

		.sort_input {
		}

		.sort_div {
			margin: 10px 75px;
			float: left;
		}

		.div_btn input {
			width: 7%;
		}

		div.cate-wrapper ul.cate-list {
			max-height: 400px;
			overflow: auto
		}

		.atlas_img_div img {
			height: 240px
		}

		/*
		 * user auto tips css
		 */
		ul {
			list-style: none outside none;
			margin: 0px;
			padding: 0px;
			-webkit-padding-start: 0px;
		}

		.recipients-tips {
			font-family: Tahoma, Arial;
			position: absolute;
			background: #fff;
			z-index: 2147483647;
			padding: 2px;
			border: 1px solid #ccc;
			display: none;
			margin: 0px;
		}

		.recipients-tips li a {
			display: block;
			padding: 5px 10px;
			color: #333;
			cursor: pointer;
			font-family: Tahoma, Arial;
		}

		.recipients-tips li a:hover {
			text-decoration: none;
		}

		.recipients-tips li a em {
			font-weight: 700;
			color: #000;
			font-family: Tahoma, Arial;
		}

		.autoSelected {
			background: #f4f4f4;
			font-family: Tahoma, Arial;
		}

		.btn_margin input {
			margin: auto 50px;
		}

		.file-drop-zone {
			min-height: 198px;
		}

		.file-thumbnail-footer {
			display: none;
		}

		.audio .file-preview-frame {
			height: 28px !important;
		}

		.audio .file-drop-zone {
			min-height: 92px;
		}

		.div_btn {
			width: 100%;
		}

		.div_btn input {
			width: 7%;
		}

		{/literal}
	</style>
</head>
<body>


<div class="container" style="width:96%">
	<form action="?do=Update" method="post" enctype="multipart/form-data">
		<input type="hidden" name="Id" value="{$info['Id']}"/>
		<table id="myformtable" class="table table-bordered table-striped" align="center">
			<tbody>
			<tr>
				<td colspan="2"><h5>修改活动详情</h5></td>
			</tr>

			<tr>
				<td style="width: 120px;">名称：</td>
				<td><input type="text" id="Name" name="Name" value="{$info['Name']}" style="width: 300px"/></td>
			</tr>
			<tr>
				<td style="width: 120px;">商家ID：</td>
				<td><input type="text" id="ShopId" name="ShopId" value="{$info['ShopId']}" style="width: 100px"/></td>
			</tr>
			<tr>
				<td style="width: 120px;">最低出价：</td>
				<td><input type="text" id="MinPrice" name="MinPrice" value="{$info['MinPrice']}" style="width: 100px"/></td>
			</tr>
			<tr>
				<td style="width: 120px;">最高出价：</td>
				<td><input type="text" id="MaxPrice" name="MaxPrice" value="{$info['MaxPrice']}" style="width: 100px"/></td>
			</tr>
			<tr>
				<td style="width: 120px;">出价类型：</td>
				<td>
					<input type="radio" name="PriceType" value="0" {if $info['PriceType'] == 0}checked{/if }/>元
					<input type="radio" name="PriceType" value="1" {if $info['PriceType'] == 1}checked{/if }/>角
					<input type="radio" name="PriceType" value="2" {if $info['PriceType'] == 2}checked{/if }/>分
				</td>
			</tr>
			<tr>
				<td style="width: 120px;">奖励类型：</td>
				<td>
					<input type="radio" name="RewardType" value="1" {if $info['RewardType'] == 1}checked{/if }/>商家提供商品
					<input type="radio" name="RewardType" value="2" {if $info['RewardType'] == 2}checked{/if }/>电子券
				</td>
			</tr>
			<tr>
				<td style="width: 120px;">有效天数：</td>
				<td><input type="text" id="RewardDays" name="RewardDays" value="{$info['RewardDays']}" style="width: 100px"/><em>中奖后实物奖</em></td>
			</tr>
			<tr>
				<td style="width: 120px;">电子券ID：</td>
				<td><input type="text" id="CouponId" name="CouponId" value="{$info['CouponId']}" style="width: 100px"/><em>请核对准确后填写</em></td>
			</tr>
			<tr>
				<td style="width: 120px;">电子券数量：</td>
				<td><input type="text" id="Amount" name="Amount" value="{$info['Amount']}" style="width: 100px"/><em>中奖后可获得的数量</em></td>
			</tr>
			<tr>
				<td style="width: 120px;">最大出价次数：</td>
				<td><input type="text" id="MaxOffer" name="MaxOffer" value="{$info['MaxOffer']}" style="width: 100px"/></td>
			</tr>
			<tr>
				<td style="width: 120px;">排序：</td>
				<td><input type="text" id="Sort" name="Sort" value="{$info['Sort']}" style="width: 100px"/><em>从小到大排序</em></td>
			</tr>
			<tr>
				<td style="width: 120px;">城市：</td>
				<td><input type="text" id="CityId" name="CityId" value="1" style="width: 100px"/><em>暂时只开放醴陵 ID:1</em></td>
			</tr>
			<tr>
				<td style="width: 120px;">规则：</td>
				<td>
					<textarea class="form-control" rows="6" id="Rules" name="Rules"
					          style="width: 50%">{$info['Rules']}</textarea>
				</td>
			</tr>
			<tr>
				<td>活动规则说明：</td>
				<td>
					<textarea class="form-control" rows="6" id="Description" name="Description"
					          style="width: 50%">{$info['Description']}</textarea>
				</td>
			</tr>
			<tr>
				<td>活动开始时间：</td>
				<td><input class="form-control" id="StartTime" name="StartTime" style="width: 300px" type="text"
				           onFocus="WdatePicker({literal}{startDate:'%y-%M-%d 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'#F{$dp.$D(\'EndTime\')}'}{/literal});"
				           value="{if $info['StartTime']}{$info['StartTime']}{/if}"></td>
			</tr>
			<tr>
				<td>活动结束时间：</td>
				<td><input class="form-control" id="EndTime" name="EndTime" style="width: 300px" type="text"
				           onFocus="WdatePicker({literal}{startDate:'%y-%M-%d 23:59:59',dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'StartTime\')}'}{/literal});"
				           value="{if $info['EndTime']}{$info['EndTime']}{/if}"></td>
			</tr>
			<tr>
				<td>活动封面图：</td>
				<td>
					<input type="file" class="file_img" id="Cover" name="Cover" minW="200" minH="200" maxSize="5120"
					       data="{$info['Cover']}" onchange="verifyImg($(this))"/>
				</td>
			</tr>
			<tr>
				<td>活动内容图：</td>
				<td>
					<input type="file" class="file_img" id="ImgUrl" name="ImgUrl" minW="200" minH="200" maxSize="5120000"
					       data="{$info['ImgUrl']}" onchange="verifyImg($(this))"/>
				</td>
			</tr>
			<tr>
				<td>状态：</td>
				<td>
					<select id="Status" name="Status" class="form-control" style="width: 100px;">
						<option value="1" {if $info['Status'] == 1}selected{/if}>正在进行</option>
						<option value="2" {if $info['Status'] == 2}selected{/if}>已结束</option>
					</select>
				</td>
			</tr>
			<tr>
				<td>更新时间：</td>
				<td>{$info['UpdateTime']}</td>
			</tr>
			<tr>
				<td>创建时间：</td>
				<td>{$info['CreateTime']}</td>
			</tr>
			<tr>
				<td colspan="2" style="text-align: center;">
				<span style="display: inline-block;margin: 0px auto;" class="btn_margin">
				<input type="submit" id="add_btn" class="btn btn-primary" value="保存"/>
				<input type="button" class="btn btn-default" onclick="javascript:history.go(-1)" value="返回"/>
				</span>
				</td>
			</tr>
			</tbody>
		</table>
	</form>
</div>

{literal}
	<script type="text/javascript">


        $("#add_btn").click(function () {
            var Name = $.trim($('#Name').val());
            if (!Name.length) {
                top.swal('出错了', '请填写名称！', 'error');
                return false;
            }


            //验证头像
            var Avatar = $("#Cover").attr("info");
            var error = '';
            if (Avatar != 'yes') {
                error += "尺寸不符合规范\r\n";
            }

            if (error != '' && undefined != Avatar) {
                top.swal('出错了', error, 'error');
                return false;
            }

            return true;
        });

        //验证图片的宽和高
        function verifyImg(obj) {
            $('#div_btn').find('input').attr('disabled', 'disabled');
            var file = obj[0].files[0];

            if (file.size > 3097152) {
                obj.attr('info', 'size');
                $('#div_btn').find('input').removeAttr('disabled');
                return;
            }

            var img_url = window.URL.createObjectURL(file);

            var minW, minH;
            minW = obj.attr('minW');
            minH = obj.attr('minH');

            obj.attr('info', 'yes');

            var ImgObj = new Image();

            ImgObj.onload = function () {
                if (minW > ImgObj.width) {
                    obj.attr('info', 'no');
                }

                if (minH > ImgObj.height) {
                    obj.attr('info', 'no');
                }
                $('#div_btn').find('input').removeAttr('disabled');
            }

            ImgObj.src = img_url;
        }


        //图片上传初始化
        $(".file_img").each(function () {
            var accept = ['jpg', 'png', 'bmp', 'gif'];
            var input_obj = {
                showCaption: false,
                showClose: false,
                uploadAsync: false,
                showRemove: false,
                showUpload: false,
                uploadUrl: "#",
                language: 'zh', //设置语言
                allowedPreviewTypes: ['image'],
                allowedFileTypes: ['image'],
                allowedFileExtensions: accept,//接收的文件后缀
            };
            $(this).attr("accept", '.' + accept.join(',.'));

            var img_url = $(this).attr("data");
            if (img_url != '') {
                input_obj.initialPreview = [
                    '<img src="' + img_url + '" class="kv-preview-data file-preview-image" style="width:auto;height:160px;">'
                ];
            }
            var maxSize = $(this).attr("maxSize");
            if (maxSize > 0) {
                input_obj.maxFileSize = maxSize;
            }

            $(this).fileinput(input_obj);
        });

        //上传插件对象
        function uploadObj() {
            return obj = {
                showCaption: false,
                showClose: false,
                uploadAsync: false,
                showRemove: false,
                showUpload: false,
                uploadUrl: "#",
                language: 'zh', //设置语言
            };
        }

	</script>
{/literal}

</body>
</html>
